const reducer = (state=[
    { id: 0, text: '事情1', completed: false },
    { id: 1, text: '事情2', completed: false },
    { id: 2, text: '事情3', completed: false }
], action) => {
    switch (action.type) {
        case 'TOGGLE_TODO':
        return state.map((todo) => {
            return todo.id === action.id ? {...todo, completed: !todo.completed} : todo
        });
        default:
            return state;
    }
} 

export default reducer;